﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Minestorm.Evolved.SceneObjects;
using Microsoft.Xna.Framework;

namespace Minestorm.Evolved.GameLogic
{
    public class MapLayout
    {
        private int _selectedIndex = 0;

        public MapLayout()
        {
            MineFields = new MineField[]
            {
                new MineField(new MineFieldMapObject[]
                {
                    new Asteroid(new Vector3(-.3f, -.3f, 0), .2f, new Vector3(.9f, .8f, .7f), new Vector3(.00008f, .00008f, .00007f)),
                    new Asteroid(new Vector3(.3f, .3f, 0), .2f, new Vector3(.7f, .8f, .9f), new Vector3(.00007f, .00008f, .00008f))
                }, new Vector3(50, 10, 20), 0, true),
                new MineField(new MineFieldMapObject[]
                {
                    new Asteroid(new Vector3(.3f, -.3f, 0), .2f, new Vector3(.6f, .5f, .4f), new Vector3(.00008f, .00007f, .00008f)),
                    new Asteroid(new Vector3(.3f, .3f, 0), .2f, new Vector3(.4f, .5f, .6f), new Vector3(.00007f, .00008f, .00008f)),
                    new Asteroid(new Vector3(-.3f, -.3f, 0), .2f, new Vector3(.4f, .6f, .5f), new Vector3(.00008f, .00008f, .00007f))
                }, new Vector3(100, 100, -30), 1, false),
                new MineField(new MineFieldMapObject[]
                {
                    new Asteroid(new Vector3(.3f, .3f, 0), .2f, new Vector3(.3f, .2f, .1f), new Vector3(.00008f, .00008f, .00008f))
                }, new Vector3(150, -80, 0), 2, false),
                new MineField(new MineFieldMapObject[]
                {
                    new Asteroid(new Vector3(-.3f, .3f, 0), .2f, new Vector3(.9f, .6f, .3f), new Vector3(.00008f, .00008f, .00008f))
                }, new Vector3(200, 0, -70), 3, false)
            };
        }

        public MineField[] MineFields { get; private set; }

        public MineField GetCurrentSelectedMineField()
        {
            return MineFields[_selectedIndex];
        }

        public MineField SelectNextMineField()
        {
            MineFields[_selectedIndex].Selected = false;

            _selectedIndex++;

            if (_selectedIndex == MineFields.Length)
                _selectedIndex = 0;

            MineFields[_selectedIndex].Selected = true;

            return GetCurrentSelectedMineField();
        }

        public MineField SelectPreviousMineField()
        {
            MineFields[_selectedIndex].Selected = false;

            _selectedIndex--;

            if (_selectedIndex == -1)
                _selectedIndex = MineFields.Length - 1;

            MineFields[_selectedIndex].Selected = true;

            return GetCurrentSelectedMineField();
        }
    }
}
